package com.toby.ioc.processor;

import com.toby.ioc.component.TobyBean;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;

/**
 * @desc: bean的后置处理器
 * @author: toby
 * @date: 2019/7/13 2:08
 */
@Component
public class TobyBeanPostProcessor implements BeanPostProcessor {
    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        if(bean instanceof TobyBean){
            System.out.println("马上开始初始化TobyBean了，注意下");
        }
        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        if(bean instanceof TobyBean){
            System.out.println("初始化完成TobyBean了，注意下");
        }
        return bean;
    }
}
